
IddTankRespawnDialog = 1230;
IdcCbHumanRespawnList = 1231;
IdcTankMap= 1232;
IdcBtMatrixInsert =1233;
IdcCbWeaponList=1234;
IdcCbAmmoList=1235;
IdcBtAddWeapon=1236;
IdcBtAddAmmo=1237;
IdcCbCabList=1238;
IdcBtMatrixExtract=1239;
IdcCbHumanExtractList=1240;
IdcDdlFollowList=1241;
IdcBtFollowHuman=1242;

IddTankDialog = 1230;

IsFollowHuman=false;

endDialog=false;
HumanFollowList=[];
HumanFollowing=h1;

CamAngle=0;
CamDistance=10;
CamHeight=0;



BtFollowHuman_click={

	if(IsFollowHuman)then{
		TankMap ctrlSetPosition [ ctrlPosition TankMap select 0,  ctrlPosition TankMap select 1, safeZoneW, safeZoneH];
		
		TankMap ctrlCommit 0.5;
		ctrlSetText [IdcBtFollowhuman,"Suivre a la 3eme personne"];	
		//TankMap ctrlShow true;
		IsFollowHuman=false;
	}else{		
		TankMap ctrlSetPosition [ ctrlPosition TankMap select 0,  ctrlPosition TankMap select 1, 0.3, 0.3];
		
		ctrlSetText [IdcBtFollowhuman,"Afficher la carte"];	
		TankMap ctrlCommit 0.5;
		
		_index=lbCurSel DdlFollowList;
		HumanFollowing=HumanFollowList select _index;
		
		[] ExecVM "TankFollowHuman.sqf";
		IsFollowHuman=true;
		
	};
	
	
};

DdlFollowList_SelChanged={
	_index=lbCurSel DdlFollowList;
	HumanFollowing=HumanFollowList select _index;
	HumanFollowing switchCamera "external";
};

endDialog=false;
		
	
while {true} do{

scopeName "dialogLoop";
	
	_TankRespawnDialog = createDialog "TankRespawnDialog";
    _TankDialog=findDisplay IddTankDialog;
		
   
	TankMap = (_TankDialog displayCtrl IdcTankMap);
	DdlFollowList = (_TankDialog displayCtrl IdcDdlFollowList);
	BtFollowHuman = (_TankDialog displayCtrl IdcBtFollowHuman);
	//CbHumanExtractList= (_TankDialog displayCtrl IdcCbHumanExtractList);;
	
	
	BtFollowHuman ctrlSetEventHandler ["ButtonClick","['',_this] call BtFollowHuman_click"];
	DdlFollowList ctrlSetEventHandler ["LBSelChanged","['',_this] call DdlFollowList_SelChanged"];
		
	_HandleUpdateFollowList = DdlFollowList execVM "Dialogs\TankRespawnDialog_UpdateFollowList.sqf"; 
	
    ctrlShow [IdcBtMatrixInsert,false];
	ctrlShow [IdcBtMatrixExtract,false];	
	
	ctrlShow [IdcCbHumanRespawnList,false];
	ctrlShow [IdcCbWeaponList,false];
	ctrlShow [IdcBtAddWeapon,false];
	ctrlShow [IdcCbCabList,false];
	ctrlShow [IdcCbHumanExtractList,false];	
	
	//----------------------------------
	
	TankMap ctrlSetPosition [ ctrlPosition TankMap select 0,  ctrlPosition TankMap select 1, safeZoneW, safeZoneH];
	TankMap ctrlCommit 0;
	
	waitUntil { (!dialog) or endDialog };
	
	// kill update threads
	
	terminate _HandleUpdateFollowList;
	
	"You exit the dialog" call debug;
	
	
    if(endDialog)then{
       
       breakOut "dialogLoop";
	   
    }else{
	
		sleep 4;
		
	};
};